package mysql

import (
	"gorm.io/gorm"
)

type Good struct {
	gorm.Model
	UserId     int     `gorm:"type:int;not null;comment:'用户Id'"`
	GoodTitle  string  `gorm:"type:varchar(50);not null;comment:'商品标题'"`
	GoodStock  int     `gorm:"type:int;not null;comment:'商品库存'"`
	GoodStatus int     `gorm:"type:int;not null;comment:'商品状态'"`
	GoodPrice  float32 `gorm:"type:double(10,2);not null;comment:'商品价格'"`
}

func (g *Good) Create() error {
	return DB.Create(&g).Error
}

func (g *Good) GetGood(id int) error {
	return DB.Where("id = ?", id).Limit(1).Find(&g).Error
}
